import BaseUtil from '@/BaseUtil';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 冰爆
 **/
export default class BossSpell_IceBoom extends AbilityBase {
    static instance: BossSpell_IceBoom;
    buffType: AppBuffType = {
        id: 'buff_BossSpell_IceBoom',
        art: this.art,
        name: this.abilityName,
        ubertip: this.ubertip,
        attribute: {
            move_speed: -30,
        },
        dur: 4,
        isDebuff: true,
    };
    constructor(id: string = 'Mxy1') {
        super(id);
        BossSpell_IceBoom.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BossAbilityManagerInstance.text('冰爆', source);
        let x = GetUnitX(source);
        let y = GetUnitY(source);
        let facing = GetUnitFacing(source);
        BaseUtil.runLater(1, () => {
            BaseUtil.onTimer(0.5, (c) => {
                let dis = 75 * c;
                let ang = facing + 50 * c;
                for (let i = 0; i < 6; i++) {
                    let ag = ang + 60 * i;
                    let tx = x + dis * Cos(ag);
                    let ty = y + dis * Sin(ag);
                    DestroyEffect(AddSpecialEffect('Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl', tx, ty));
                    let es = SelectUtil.getEnemyUnitsInRange(source, 75, tx, ty);
                    DamageSystemInstance.applyAoeMagicDamage(es, source, 600, 'ice');
                    for (let e of es) {
                        BuffUtil.addBuff(e, this.buffType.id, source);
                    }

                    if (c >= 8) {
                        source = null;
                    }
                }
                return c < 8;
            });
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
